home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#38 (Nov 88)
/
IAC
/
New Driver Stuff
/
SAWSINIT.a
< prev
next >
Wrap
Text File
|
1988-08-21
|
3KB
|
109 lines
;******************************************************************************
;***** The SAWS Inter-Application Communication Driver Loader *****
;***** Written with blazing speed 6-7/88 by Paul F. Snively *****
;***** With one HELL of a lotta help from Frank Alviani *****
;******************************************************************************
;
;Modification History:
;6/19/88 First Draft--Paul F. Snively
;7/10/88 Hopefully last draft--this SHOULD work--Paul F. Snively
;8/21/88 Now searches for open slot from end of table--Frank Alviani
; (Algorithm from Pete Helme, Apple MACDTS)
;
;Basically what this puppy does is to assume that there's a DRVR resource lying
;around that happens to be named ".IAC" and, if there is, it loads it into the
;System Heap and opens it. Simple, huh?
;
INCLUDE 'Traps.a'
INCLUDE 'QuickEqu.a'
INCLUDE 'SysEqu.a'
INCLUDE 'ToolEqu.a'
; STRING ASIS
successID EQU 128
failureID EQU 129
SAWSINIT: PROC
IMPORT ShowINIT
Frame RECORD 4,DECR
return DS.L 1
A6Link DS.L 1
theID DS.W 1
theType DS.L 1
name DS.B 256
fSize EQU *
ENDR
LINK A6,#Frame.fSize ;space for locals...
; Find an open slot in the driver table and load into that
MOVE.W UnitNtryCnt,D2 ;How many slots?
SUBQ.W #1,D2 ;Adjust
MOVE.W D2,D1 ;Set up offset
LSL.W #2,D1
MOVEA.L UTableBase,A0 ;Where's the table?
SrchLoop
TST.L 0(A0,D1.W) ;Available?
BEQ.S GotSlot ;Yup...
SUBQ.L #4,D1 ;Drop Offset
SUBQ.W #1,D2 ;Drop slot ID
CMPI.L #39,D2 ;At bottom limit?
BGT.S SrchLoop
BRA.S BadNews ;No open slots in the inn
;Get resource by name
GotSlot
SUBQ.W #4,A7 ;Space for handle
MOVE.L #$44525652,-(A7) ;'DRVR'
PEA DriverName
_GetNamedResource
MOVE.W ResErr,D0 ;Get it?
BNE.S BadNews
MOVE.L (A7)+,D7 ;Was there enough memory?
BEQ.S BadNews
;Change ID to open slot
MOVE.L D7,-(A7)
PEA Frame.theID(A6) ;ID
PEA Frame.theType(A6) ;theType
PEA Frame.name(A6) ;name
_GetResInfo
MOVE.L D7,-(A7)
MOVE.W D2,-(A7)
PEA Frame.name(A6) ;name
_SetResInfo
;Open the driver!
CLR.W -(A7) ;Room for refnum
PEA DriverName ;Point to driver name
_OpenDeskAcc ;Open it
MOVE.W (A7)+,D1 ;Pop refnum
;Ensure Driver undisturbed
MOVE.L D7,-(A7)
_DetachResource
;Restore previous slot in file
MOVE.L #$44525652,-(A7) ;'DRVR'
PEA DriverName
_GetNamedResource
MOVE.L D7,-(A7)
MOVE.W Frame.theID(A6),D0
MOVE.W D0,-(A7)
MOVE.L #0,-(A7) ;leave alone name
_SetResInfo
MOVE.W #successID,-(SP) ;Stack success ICN# ID
ShowICON:
MOVE.W #-1,-(SP) ;Use standard pixel offset
MOVE.L (SP)+,D0 ;TEMPORARY! POP OFF PARMS
; JSR ShowINIT ;Tell user that driver installed
UNLK A6
RTS ;And that's all, folks!
BadNews:
MOVE.W #failureID,-(SP) ;Tell user we failed miserably
BRA.S ShowICON ;And leave
DriverName:
DC.B '.IAC' ;The name of our driver
ENDPROC
END